package FirstStage.FengZhuang;

public class FengZhuang {
    public static void main(String[] args) {
        person p = new person("jackandmack",30,10000);
        p.info();
    }
}


class person{
    public person() {
    }

    public person(String name, int age, double salary) {
        this.setName(name);
        this.setAge(age);
        this.setSalary(salary);
    }

    public String name;
    private int age;
    private double salary;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if(name.length()>=2 && name.length()<=6){
            this.name = name;
        }else {
            this.name="无名";
        }

    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age>=1 && age<=120){
            this.age = age;
        }else {
            this.age = 18; //设置的年龄不对，给一个默认年龄
        }
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }



    public void info(){
        System.out.println("name="+ name + "age="+age+ "salary="+salary);
    }
}